package com.lewin.ringroad.entity;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author Jun
 * @since 1.0.0
 */
@Data
@Accessors(chain = true)
public class RadarStatisticsDataPO {

    public static RadarStatisticsDataPO init(String bizId) {
        return new RadarStatisticsDataPO()
                .setBizId(bizId)
                .setTraffic(0)
                .setAverageSpeed(0d)
                .setOccupationRate(0d)
                .setQueueLen(0d);
    }

    private Integer id;

    private String bizId;

    private Integer traffic;

    private Double averageSpeed;

    private Double occupationRate;

    private Double queueLen;

    /**
     * yyyyMMddHH
     */
    private String timeAt;

    public RadarStatisticsDataVO toVO() {
        return new RadarStatisticsDataVO()
                .setTraffic(traffic)
                .setAverageSpeed(averageSpeed)
                .setOccupationRate(occupationRate)
                .setQueueLen(queueLen)
                .setTimeAt(timeAt);
    }


    public void clear() {
        this.traffic = 0;
        this.averageSpeed = 0d;
        this.occupationRate = 0d;
        this.queueLen = 0d;
    }

    public boolean isValidData() {
        return traffic > 0 || averageSpeed > 0 || occupationRate > 0 || queueLen > 0;
    }
}
